# 子类重写父类的属性和方法, 优先会调用子类的属性和方法

# 1 定义师父类 实现init函数 make_cake函数
class Master(object):
    def __init__(self):
        self.kongfu = '[传统方法]'

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')


# 2 定义HeimaSchool类 /kongfu /make_cake
class HeimaSchool(object):
    def __init__(self):
        self.kongfu = '[黑马配方]'

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')


# 2 定义徒弟类 继承Master HeimaSchool
# class Prentice(Master, HeimaSchool):
class Prentice(HeimaSchool, Master):
    def __init__(self):
        self.kongfu = '[独创摊煎饼技术]'

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')
        pass
    pass


# 3 实例化徒弟类, 调用属性/调用方法
xiaoming = Prentice()  # 注: 实例化类对象,不要忘()
print(xiaoming.kongfu)
xiaoming.make_cake()


# 4 通过子类的mro()方法 __mro__属性 查看父类的先后顺序 返回一个列表
print(Prentice.mro())
print(Prentice.__mro__)

# [<class '__main__.Prentice'>,
# <class '__main__.HeimaSchool'>,
# <class '__main__.Master'>,
# <class 'object'>]


